import pymysql
import pyodbc

from Base.GetYamlFile import getYamlPath

sql_config = getYamlPath("SqlConfigConcrete")
basic_conn = pymysql.connect(**sql_config)
cur = basic_conn.cursor()

dp_order_sql = '''
        SELECT
            sdo.other_id as other
        FROM
            sales_dp_order sdo 
        WHERE
            sdo.bill_date >= '2023-12-01 00:00:00' 
            AND sdo.bill_date <= '2023-12-31 23:59:59' 
            AND sdo.is_delete = 0 
            AND sdo.`status` = 1;
	'''
test = cur.execute(dp_order_sql)
print(test)
test = cur.fetchall()
list1 = []

for item in test:
    list1.append(item[0])

print(list1)

connection_string = (
    r'DRIVER={SQL Server Native Client 10.0};'
    r'SERVER=192.168.17.28;'
    r'DATABASE=master;'
    r'UID=laihui;'
    r'PWD=Www.1.com;'
)
pro_sql = '''
SELECT SUM(SL) FROM KF_PCB WHERE ENDTime >= '2023-12-01 00:00:00' AND ENDTime <='2023-12-31 23:59:59' AND FCID=1 AND XH not in ({}) ;
'''.format(','.join(map(str, list1)))
cnxn = pyodbc.connect(connection_string)
cursor = cnxn.cursor()
cursor.execute("")
rows = cursor.fetchall()

for row in rows:
    print(row)
